package com.demo.structure;

import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Arrays;
import java.util.List;

@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class UserStruct extends Structure {

    public UserStruct(Pointer pointer) {
        super(pointer);
    }

    public static class ByReference extends UserStruct implements Structure.ByReference{ }

    public static class ByValue extends UserStruct implements Structure.ByValue{ }

    public static final int NAME_LEN = 10;

    public static final int MARK_LEN = 255;

    public int id;

    public byte[] name = new byte[NAME_LEN];
    public double high;
    public long timestamp;
    public byte[] mark = new byte[MARK_LEN];

    @Override
    protected List<String> getFieldOrder() {
        return Arrays.asList("id", "name", "high", "timestamp",  "mark");
    }
}
